package com.wm.entity;

/**
 * @ClassName:Ticket
 * @Description:
 * @Author:Deamer
 * @Date:2022/1/17 22:43
 **/
public class Ticket {
    // 票数
    private int number = 30;

    // 操作方法：售票
    public synchronized void sale() {
        if (number > 0) {
            System.out.println(Thread.currentThread().getName() + "卖出：" + (number--) + "剩下：" + number);
        }
    }

    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {

            }
        }, "AA").start();
    }
}
